package News.servlet;

import News.service.Server;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class deleteServlet extends HTTPServlet {

    protected void doGet(HttpServletRequest rq, HttpServletResponse rs) throws ServletException, IOException {
        String title=(String)rq.getParameter("title");
        String content=(String)rq.getParameter("content");
        String fromto=(String)rq.getParameter("fromto");
        String sendto=(String)rq.getParameter("sendto");
        String selectUserName="SELECT `userName` FROM WSQ.user where `userId`="+fromto;
        Server s=new Server();
        String username=s.selectUsername(selectUserName);
        String sql="insert into WSQ.user_msg (`username`,`fromto`,`sendto`,`title`,`content`) values('"+username+"',"+sendto+","+fromto+",'"+title+"','"+content+"')";

        int i=0;
        i=s.update(sql);
        boolean judge=false;
        if(i>0){
            judge=true;
        }else{
            judge=false;
        }
        rs.setContentType("text/html;charset=UTF-8");
        PrintWriter pw=rs.getWriter();
        pw.print(judge);
        pw.flush();
        pw.close();
    }
}
